<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h1>欢迎光临_vue开发的收银系统_水果店</h1>
      <p>苹果 10￥/斤, 折扣 8折</p>
      <label>请输入你要购买的斤数</label>
      <input type="number" v-model="count1" />
      <button @click="checkout">结账买单~</button>
      <div id="receipt">
        <p>
          结账单: 总价: {{ totalPrice }} ￥ 折后价: {{ discountedPrice }} ￥
          省了: {{ savings }} ￥
        </p>
      </div>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          count: 0,
          count1: 0,
        },
        methods: {
          checkout() {
            this.count = this.count1;
          },
        },
        computed: {
          totalPrice() {
            return this.count * 10;
          },
          discountedPrice() {
            return this.totalPrice * 0.8;
          },
          savings() {
            return this.totalPrice - this.discountedPrice;
          },
        },
      });
    </script>
  </body>
</html>
